package practice09;

public class Person {
    //写一个Person类，要有id，name，age属性，靠id来判断是否是同一个人。要有一个introduce方法，


    Integer id;
    String name;
    Integer age;
    public Person(Integer id, String name, Integer age) {
        this.id=id;
        this.name=name;
        this.age=age;
    }

    public Integer getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
    //introduce方法返回一个字符串形如：
    //>My name is Tom. I am 21 years old.
    public String introduce() {
        return "My name is "+name+". I am "+age+" years old.";
    }
//靠id来判断是否是同一个人
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return id.equals(person.id);
    }

    @Override
    public int hashCode() {
        return id;
    }

}
